package com.warrior.superdata.annotation.aspect;

import com.warrior.superdata.annotation.MysqlCheckInject;
import com.warrior.superdata.util.MysqlCheckUtil;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @ClassName: com.warrior.wisdom.machine.room.annotation.aspect.MysqlCheckAspect.java
 * @date: 2021/12/28 15:17
 * @author xujian
 */
@Aspect
@Component
@Slf4j
@Order(2)
public class MysqlCheckAspect {

    @Around("@annotation(mysqlCheckInject)")
    public Object around(ProceedingJoinPoint pjp, MysqlCheckInject mysqlCheckInject) throws Throwable {
        Object[] args = pjp.getArgs();
        Object obj = args[0];
        String method = mysqlCheckInject.method();
        MysqlCheckUtil.check(obj, method);
        return pjp.proceed(args);
    }

}
